<html>
<head>
<#import "/common/common.ftl" as netCommon>
<@netCommon.commonStyle />
<title></title>
<@netCommon.commonScript /> 
<@netCommon.commonLayui /> 
</head>
<body class="layui-layout-body show-scroll-y">
	<div class="layuimini-container">
		<div class="layui-row">
			<table class="layui-table">
				<tr>
					<td style="width: 120px;">授权状态</td>
					<td>
						<span class="license-error" id="licenState">
							未授权
						</span>
					</td>
				</tr>
				<tr>
					<td>系统版本</td>
					<td id="sysVersion">*.*</td>
				</tr>
				<tr>
					<td>注 册 码</td>
					<td id="licenKey">******************</td>
				</tr>
				<tr>
					<td>单　　位</td>
					<td id="org">******************</td>
				</tr>
				<tr>
					<td>有效期至</td>
					<td id="endDate">1900年01月01日</td>
				</tr>
				<tr>
					<td colspan="2">
						<form class="layui-form" lay-filter="editFrom" id="editFrom" action="">
							<div class="layui-row">
								<input type="text" name="licenseCode" id="licenseCode" lay-verify="required"
									placeholder="请输入授权许可"  class="layui-input" value="" />
							</div>
							<div class="layui-row" style="text-align: center;margin-top: 10px;">
								<button type="submit" class="layui-btn" lay-submit lay-filter="saveBtn">
									<i class="layui-icon">&#xe605;</i>提交授权码
								</button>
							</div>
						</form>
					</td>
				</tr>
			</table>
		</div>
	</div>
	<script type="text/javascript">
	layui.use(["form","layer"], function(){
		var layform = layui.form;
		$(function(){
			loadThisLicense();
			loadLicenKey();
		});
		layform.on("submit(saveBtn)",function(){
			var pData = layform.val('editFrom');
			$.ajax({
				url: basePath+"/license/doSaveLicense",
				type: "post",
				dataType: "json",
				data: pData,
				success: function(data){
					var licen = data.data;
					initLicenState(licen);
				}
			});
			return false;
		});
	});
	function loadLicenKey(){
		$.ajax({
			url: basePath+"/license/thisLicenseKey",
			type: "post",
			dataType: "json",
			success: function(data){
				if(data.code == "0"){
					$("#licenKey").html(data.data);
				}else{
					$("#licenKey").html(data.msg);
				}
			}
		});
	}
	function loadThisLicense(){
		$.ajax({
			url: basePath+"/license/thisLicense",
			type: "post",
			dataType: "json",
			success: function(data){
				var licen = data.data;
				initLicenState(licen);
			}
		});
	}
	function initLicenState(licen){
		$("#sysVersion").html(licen.version);
		$("#org").html(licen.org);
		$("#endDate").html(dateFormat(licen.endDate));
		if(licen.state == "0"){
			$("#licenState").removeClass("license-error");
			$("#licenState").addClass("license-ok");
			$("#licenState").html("已授权");
		}else{
			$("#licenState").removeClass("license-ok");
			$("#licenState").addClass("license-error");
			$("#licenState").html(licen.errMsg);
		}
	}
	</script>
</body>
</html>